Add example using implementing Extension for APO emulation#32
Add example using implementing Extension for APO emulation#32sanket1729 wants to merge 6 commits intoElementsProject:masterfrom
Extension for APO emulation#32Conversation
All other descriptor APIs only deal with sane miniscripts
Ideally, we want to do using more granular components defined in the library. As a simple example, this implements apo as a single fragment.
| // Try parsing with extensions | ||
| let tr = Tr::<Pk, T>::from_str(s)?; | ||
| // descriptors are always parsed insane. This will improve once we use upstream ExtParams Api. | ||
| let tr = Tr::<Pk, T>::from_str_insane(s)?; |
There was a problem hiding this comment.
In acced27:
This is a bit eyebrow-raising. This means that Descriptor::from_str will no longer enforce any sanity rules when parsing tapscripts?
This is fine if it's temporary and we're going to fix it when we bring ExtParams down, but the comment should have the text FIXME in it so that we have a reminder to deal with it.
There was a problem hiding this comment.
Sorry, this comment was wrong/incomplete. This was meant to covenant descriptors should be parsed as insane because they are not safe(in the sense there is no signature guarding it).
Parsing regular descriptors should work as expected.
There was a problem hiding this comment.
Okay, perfect. Can you update the comment?
| /// The data that needs to be signed in apo + all. | ||
| /// We can decompose this into into individual parts for fixing version, amt, script pubkey | ||
| /// | ||
| /// This structure is onyl an example of how one might implement extension. We do pay any |
There was a problem hiding this comment.
Also do pay should be do not pay I think :)
|
|
||
| use opcodes::all::*; | ||
| builder = builder | ||
| .push_opcode(OP_INSPECTVERSION).push_slice(&self.version.to_le_bytes()).push_opcode(OP_EQUALVERIFY) |
There was a problem hiding this comment.
In 66aeb41:
I would really prefer that all the .push_ methods got their own line.
There was a problem hiding this comment.
Ok, on closer reading I see that the reason is that you've got INSEPECTXXX <XXX> EQV all on one line ... so I feel less strongly. But I'd still suggest breaking it up across separate lines and maybe adding comments in between to separate the sections.
|
This looks great! Super cool to see how APO works. One thing that confuses me here is that it seems you're only validating the one input -- is this how APO is supposed to work? This seems like it's SighashAll + ANYONECANPAY + ANYPREVOUT rather than just all+apo. It also seems unfortunate that you need to commit to the target data in the scriptpubkey, but for an example implementation I think that's fine. (I think what we'd actually like to do is add a Done reviewing 66aeb41. |
APO is similar to ACP, but not that we do not commit to the previous outpoint here. If this was ACP, we would be committing to Outpoint. |
Follows BIP118, without fixing the annex. Annex introspection is not currently supported.